<!--{template common/header_simple_start}-->
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
<link href="dzz/connect/images/connect.css?{VERHASH}" rel="stylesheet" media="all">
<script type="text/javascript" src="dzz/scripts/jquery-1.10.2.min.js"></script>
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>

<!--{template common/header_simple_end}-->
<div class="container" style="height:100%">
	<div class="main-header clearfix">
		<ul class="nav nav-pills nav-pills-bottomguide">
			<li>
				<a href="{BASESCRIPT}?mod=connect">{lang my_clouds}</a>
			</li>
			<li>
				<a href="{BASESCRIPT}?mod=connect&op=addcloud">{lang add_clouds}</a>
			</li>
			<li class="active">
				<a href="{BASESCRIPT}?mod=connect&op=oauth&bz=ALIOSS">{lang add_oauth_JSS_JD_storage}</a>
			</li>
		</ul>
	</div>
	<div class="main-content clearfix">
		<div class="container" style="padding:15px;">
			<h4 class="clearfix" style="margin-bottom:20px"><div class="col-sm-1"></div><div class="col-sm-10">{lang set}cess Key ID {lang and} Access Key Secret</div></h4>
			<form name="aliform" class="form-horizontal" action="{BASESCRIPT}?mod=connect&op=oauth" method="post" onsubmit="return validate(this)">
				<input type="hidden" name="jsssubmit" value="true" />
				<input type="hidden" name="bz" value="JSS" />
				<input type="hidden" name="formhash" value="{FORMHASH}" />
				<div class="form-group">
					<label class="control-label col-sm-3" for="email">accessKey</label>
					<div class="col-sm-4">
						<input type="text" id="access_id" class="form-control" name="access_id" autocomplete="off" value="" onblur="if(this.value==''){jQuery(this).parent().parent().addClass('warning');}else{jQuery(this).parent().parent().removeClass('warning');getBucket();}">
					</div>
					<div class="col-sm-5">
						<span class="help-inline">{lang oauth_JSS_JD_storage}accessKey</span>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3" for="email">secretKey</label>
					<div class="col-sm-4">
						<input type="password" class="form-control" id="access_key" name="access_key" autocomplete="off" value="" onblur="if(this.value==''){jQuery(this).parent().parent().addClass('warning');}else{jQuery(this).parent().parent().removeClass('warning');getBucket();}">
					</div>
					<div class="col-sm-5">
						<span class="help-inline">{lang oauth_JSS_JD_storage}secretKey</span>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-sm-3"><a href="javascript:;" onclick="getBucket()">{lang oauth_ALIOSS_click_gain}</a></label>
					<div class="col-sm-4">
						<select id="bucket" name="bucket" class="form-control">
							<option value="">{lang please_choose}bucket</option>
						</select>
					</div>
					<div class="col-sm-4">
						<span class="help-inline">{lang oauth_JSS_bucket}</span>
					</div>
				</div>
				<div class="form-group">
					<div class="col-sm-3"></div>
					<div class="col-sm-9">
						<input type="submit" class="btn btn-primary" value="{lang add}">
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<script type="text/javascript">
	function getBucket() {
		var id = encodeURIComponent(jQuery("#access_id").val());
		var key = encodeURIComponent(jQuery("#access_key").val());
		if(id == '' || key == '') {
			return;
		}
		jQuery.getJSON(DZZSCRIPT + '?mod=connect&op=ajax&do=getBucket&bz=JSS', { id: id, key: key }, function(json) {
			if(json.error) {
				alert(json.error);
			} else if(json.length > 0) {
				var html = '<option value="" >{lang please_choose}bucket</option>';
				for(var i in json) {
					html += '<option value="' + json[i] + '" >' + json[i] + '</option>';
				}
				jQuery('#bucket').html(html);
			}
		});

	}

	function validate(form) {
		if(jQuery("#access_id").val() == '') {
			jQuery("#access_id").parent().parent().addClass('warning');
			return false;
		} else if(jQuery("#access_key").val() == '') {
			jQuery("#access_key").parent().parent().addClass('warning');
			return false;
		}
		return true;
	}
	jQuery(document).ready(function(e) {

	});
</script>
<!--{template common/footer_simple}-->